package com.visitor.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class SecurityConfig {

        @Bean
        public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
            http
                    .csrf().disable() // 关闭 CSRF
                    .cors().and()     // 开启 CORS 支持（如果你有跨域需求）
                    .authorizeHttpRequests()
                    .anyRequest().permitAll() // 所有请求都放行
                    .and()
                    .formLogin().disable()   // 关闭默认登录表单
                    .httpBasic().disable();  // 关闭 basic 弹窗认证

            return http.build();
        }
    }

